package com.suoluo.zenadmin.controllers.admin.dest;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import net.paoding.rose.web.Invocation;
import net.paoding.rose.web.annotation.Param;
import net.paoding.rose.web.annotation.Path;
import net.paoding.rose.web.annotation.rest.Get;
import net.paoding.rose.web.annotation.rest.Post;

import com.suoluo.zenadmin.common.CommonResp;
import com.suoluo.zenadmin.common.JSONPageData;
import com.suoluo.zenadmin.common.config.SystemConfigHolder;
import com.suoluo.zenadmin.controllers.JSONInterceptor.JSON;
import com.suoluo.zenadmin.service.InfoService;
import com.suoluo.zenadmin.service.dest.DestFeatureCategoryService;
import com.suoluo.zenadmin.service.dest.DestService;
import com.suoluo.zenadmin.service.dest.DestTrafficService;
import com.suoluo.zenadmin.vo.BaseInfoVO;
import com.suoluo.zenadmin.vo.ImageVO;
import com.suoluo.zenadmin.vo.PageVO;
import com.suoluo.zenadmin.vo.dest.DestActivityVO;
import com.suoluo.zenadmin.vo.dest.DestFeature2VO;
import com.suoluo.zenadmin.vo.dest.DestFeatureCategoryVO;
import com.suoluo.zenadmin.vo.dest.DestFeatureItem2VO;
import com.suoluo.zenadmin.vo.dest.DestTraffic2VO;
import com.suoluo.zenadmin.vo.dest.DestVO;
import com.suoluo.zenadmin.vo.dest.SelectFeatureItemVO;
import com.suoluo.zenadmin.vo.hotel.Hotel2VO;

@Path("/")
public class DestController {
	
	@Resource(name="destService")
	private DestService destService;
	@Resource(name="infoService")
	private InfoService infoService;
	@Resource(name="categoryService")
	private DestFeatureCategoryService categoryService;
	@Resource(name="destTrafficService")
	private DestTrafficService destTrafficService;
	/**************************featureCategory**start******************************/
	@Get("feature/category/vlist")
	public String toListDestFeatureCategory()
	{
		return "listDestFeatureCategory";
	}
	@JSON
	@Post("feature/category/list")
	public Object listDestFeatureCategory()
	{
		return categoryService.findListDestFeatureCategory();
	}
	@Get("feature/category/vsave")
	public String toAddCategory()
	{
		return "addDestFeatureCategory";
	}
	@JSON
	@Post("feature/category/save")
	public Object saveCategory(DestFeatureCategoryVO category)
	{
		categoryService.saveDestFeatureCategory(category);
		return CommonResp.SUCCESS;
	}
	
	@Get("feature/category/vupdate")
	public String toUpdateCategory(Invocation invo,@Param("categoryId")int categoryId)
	{
		
		DestFeatureCategoryVO category = categoryService.findDestFeatureCategoryById(categoryId);
		invo.addModel("categoryInfo",category);
		return "updateDestFeatureCategory";
	}
	@JSON
	@Post("feature/category/listParentCategory")
	public Object listParentCategory()
	{
		return categoryService.findRootCategoryWithoutExperience();
	}
	@JSON
	@Post("feature/category/update")
	public Object updateCategory(DestFeatureCategoryVO category)
	{
		categoryService.updateDestFeatureCategory(category);
		return CommonResp.SUCCESS;
	}
	@Get("feature/vupdate/special")
	public String toUpdateCategorySpecial(Invocation invo)
	{
		int categoryId = Integer.parseInt(invo.getParameter("categoryId"));
		DestFeatureCategoryVO category = categoryService.findDestFeatureCategoryById(categoryId);
		invo.addModel("category",category);
		return "updateFeatureCategorySpecial";
	}
	@JSON
	@Post("feature/category/delete")
	public Object deleteCategory(DestFeatureCategoryVO categoryVO)
	{
		categoryService.deleteDestFeatureCategory(categoryVO);
		return CommonResp.SUCCESS;
	}
	/**************************featureCategory**end******************************/
	
	/**************************TravelDestination**start******************************/
	@Get("vlist")
	public String toListTravelDestination()
	{
		return "listTraveldestination";
	}
	@JSON
	@Post("list")
	public JSONPageData listTravelDestination(Invocation invo,PageVO page)
	{
		String destName = invo.getParameter("destName");
		JSONPageData data = new JSONPageData();
		List<DestVO> list = destService.findSimplestDests(destName,page);
		data.setRows(list);
		int total = destService.findDestCount(destName);
		data.setTotal(total);
		return data;
	}
	@Get("vsave")
	public String toAddTravelDestination()
	{
		return "addDestination";
	}
	@JSON
	@Post("listCountry")
	public Object listCountry()
	{
		return destService.findCountries();
	}
	@JSON
	@Post("save")
	public Object saveTravelDestination(DestVO destVO)
	{
		destService.saveDest(destVO);
		return CommonResp.SUCCESS;
	}
	@Get("vupdate")
	public String toUpdateTravelDestination(Invocation invo,@Param("destId")int destId)
	{
		DestVO destVO = destService.findDestById(destId);
		invo.addModel("dest",destVO);
		return "updateDestination";
	}
	@JSON
	@Post("update")
	public Object updateDest(DestVO destVO)
	{
		destService.updateDest(destVO);
		return CommonResp.SUCCESS;
	}
	@JSON
	@Post("delete")
	public Object deleteDest(DestVO destVO){
		destService.deleteDest(destVO);
		return CommonResp.SUCCESS;
	}
	/**************************TravelDestination**end******************************/
	/**************************DestActivity**start******************************/
	@Get("activity/vlist")
	public String toListDestActivity(Invocation invo,@Param("destId")int destId)
	{
		DestVO dest = destService.findDestById(destId);
		invo.addModel("dest",dest);
		return "listDestActivityInfo";
	}
	@JSON
	@Post("activity/list")
	public Object listDestActivity(@Param("destId")int destId)
	{
		return destService.findListDestActivity(destId);
	}
	@Get("activity/vsave")
	public String toAddDestActivity(int destId)
	{
		return "addDestActivity";
	}
	@JSON
	@Post("activity/save")
	public Object saveDestActivity(DestActivityVO activity)
	{
		destService.saveDestActivity(activity);
		return CommonResp.SUCCESS;
	}
	@Get("activity/vupdate")
	public String toUpdateDestActivity(Invocation invo,@Param("activityId")int activityId)
	{
		DestActivityVO activity = destService.findDestActivityById(activityId);
		invo.addModel("destActivity",activity);
		return "updateDestActivity";
	}
	@JSON
	@Post("activity/update")
	public Object updateDestActivity(DestActivityVO activity)
	{
		destService.updateDestActivity(activity);
		return CommonResp.SUCCESS;
	}
	@JSON
	@Post("activity/delete")
	public Object deleteDestActivity(DestActivityVO activity)
	{
		destService.deleteDestActivity(activity);
		return CommonResp.SUCCESS;
	}
	
	/**************************DestActivity**end******************************/
	
	/**************************DestFeature**start******************************/
	@Get("feature/vlist")
	public String toListDestFeature(Invocation invo,@Param("destId")int destId)
	{
		DestVO dest = destService.findDestById(destId);
		invo.addModel("dest",dest);
		return "listDestFeature";
	}
	@JSON
	@Post("feature/list")
	public Object listDestFeature(@Param("destId")int destId)
	{
		return destService.findSimpleDestFeatures(destId);
	}
	@Get("feature/vsave")
	public String toAddDestFeature(Invocation invo,@Param("destid")int destId)
	{
		DestVO dest = destService.findDestById(destId);
		invo.addModel("dest",dest);
//		invo.addModel("categoryId",categoryId);
		return "addDestFeature";
	}
	@JSON
	@Post("feature/save")
	public Object saveDestFeature(DestFeature2VO category)
	{
		destService.saveDestFeature(category);
		return CommonResp.SUCCESS;
	}
	
	@Get("feature/vupdate")
	public String toUpdateDestFeature(Invocation invo,@Param("featureId")int featureId)
	{
		DestFeature2VO feature = destService.findDestFeatureById(featureId);
		invo.addModel("feature",feature);
		return "updateDestFeature";
	}
	@JSON
	@Post("feature/update")
	public Object updateDestFeature(DestFeature2VO feature)
	{
		destService.updateDestFeature(feature);
		return CommonResp.SUCCESS;
	}
//	@JSON
//	@Post("feature/noadd/category/list")
//	public Object listNoAddFeatureCategory(@Param("destId")int destId,@Param("categoryId")int categoryId)
//	{
//		return destService.findNoAddFeatureCategory(destId,categoryId);
//	}
	@JSON
	@Post("feature/delete")
	public Object deleteDestFeature(DestFeature2VO feature)
	{
		destService.deleteDestFeature(feature);
		return CommonResp.SUCCESS;
	}
	/**
	 * 跳转到选中推荐的特色项页面
	 * @return
	 */
	@Get("feature/select/item/vlist")
	public String toListSelectFeatureItem(Invocation invo,@Param("featureId")int featureId)
	{
		DestFeature2VO feature = destService.findDestFeatureById(featureId);
		invo.addModel("feature",feature);
		DestVO dest = destService.findDestById(feature.getDestId());
		invo.addModel("dest",dest);
		DestFeatureCategoryVO category = categoryService.findDestFeatureCategoryById(feature.getFeatureCategoryId());
		invo.addModel("category",category);
		return "listSelectFeatureItem";
	}
	@JSON
	@Post("feature/select/item/list")
	public Object listSelectFeatureItem(@Param("featureId")int featureId)
	{
		return destService.findListFeatureSelectItem(featureId);
	}
	@Get("feature/select/item/vsave")
	public String toAddSelectFeatureItem(Invocation invo,@Param("featureId")int featureId)
	{
		invo.addModel("featureId",featureId);
		return "selectFeatureItem";
	}
	@JSON
	@Post("feature/select/item/all")
	public Object listAddSelectFeatureItem(@Param("featureId")int featureId)
	{
		return destService.findListAllFeatureItem(featureId);
	}
	@JSON
	@Post("feature/select/item/save")
	public Object saveSelectFeatureItem(SelectFeatureItemVO itemVO)
	{
		destService.saveSelectFeatureItem(itemVO);
		return CommonResp.SUCCESS;
	}
	/**************************DestFeature**end******************************/
	/**************************DestFeatureItem**start******************************/
	@Get("feature/item/vlist")
	public String toListFeatureItem(Invocation invo,@Param("featureId")int featureId)
	{
		//调用简单的接口(Simplest)
		DestFeature2VO feature = destService.findSimplestDestFeatureById(featureId);
		invo.addModel("feature",feature);
		
		DestVO dest = destService.findSimplestDestById(feature.getDestId());
		invo.addModel("dest",dest);

		
		DestFeatureCategoryVO category = categoryService.findDestFeatureCategoryById(feature.getFeatureCategoryId());
		invo.addModel("category",category);
		int hotelFeatureType = SystemConfigHolder.getDestFeatureCategoryForHotel();
		invo.addModel("hotelFeatureType",hotelFeatureType);
		return "listDestFeatureItem";
	}
	@JSON
	@Post("feature/item/list")
	public Object listFeatureItem(@Param("featureId")int featureId)
	{
		return destService.findFeatureItemWithoutContent(featureId);
	}
	@Get("feature/item/vsave")
	public String toAddFeatureItem()
	{
		return "addDestFeatureItem";
	}
	@JSON
	@Post("feature/item/save")
	public Object saveFeatureItem(DestFeatureItem2VO itemVO)
	{
		destService.saveDestFeatureItem(itemVO);
		return CommonResp.SUCCESS;
	}
	@Get("feature/item/vupdate")
	public String toUpdateFeatureItem(Invocation invo,@Param("featureItemId")int featureItemId,@Param("destId")int destId)
	{
		DestFeatureItem2VO itemPOJO = destService.findFeatureItemById(featureItemId);
		invo.addModel("featureItem",itemPOJO);
		invo.addModel("destId",destId);
		return "updateFeatureItemInfo";
	}
	@JSON
	@Post("feature/item/update")
	public Object updateDestFeatureItem(DestFeatureItem2VO itemVO)
	{
		destService.updateDestFeatureItem(itemVO);
		return CommonResp.SUCCESS;
	}
	/**
	 * 跳转到添加住宿的特色项页面
	 * @return
	 */
	@Get("feature/item/hotel/vsave")
	public String toAddHotelFeatureItem(Invocation invo,@Param("destId")int destId,@Param("featureId")int featureId)
	{
		List<Hotel2VO> list = destService.findListDestHotel(destId, featureId);
		invo.addModel("hotelListInfo",list);
		return "addDestFeatureItemHotel";
	}
	/**
	 * 保存住宿的特色项
	 * @return
	 */
	@JSON
	@Post("feature/item/hotel/save")
	public Object saveHotelFeatureItem(DestFeatureItem2VO item)
	{
		destService.saveHotelFeatureItem(item);
		return CommonResp.SUCCESS;
	}
	@JSON
	@Post("feature/item/delete")
	public Object deleteFeatureItem(DestFeatureItem2VO item,@Param("featureCategoryId")int categoryId)
	{
		destService.deleteFeatureItem(item,categoryId);
		return CommonResp.SUCCESS;
	}
	/**************************DestFeatureItem**end******************************/
	
	/**************************目的地特色项的图文管理*start************************/
	@Get("feature/item/text/vlist")
	public String toListFeatureItemText(Invocation inv,@Param("featureItemId")int featureItemId) {
		//获取特色项信息
		DestFeatureItem2VO item = destService.findSimplestFeatureItemById(featureItemId);
		inv.addModel("item",item);
		if(item != null && item.getFeatureId() != 0) {
			//获取特色信息
			DestFeature2VO	feature = destService.findSimplestDestFeatureById(item.getFeatureId());
			inv.addModel("feature",feature);
			if(feature != null && feature.getDestId() != 0) {
				//获取目的地信息
				DestVO dest = destService.findSimplestDestById(feature.getDestId());
				inv.addModel("dest",dest);
			}
		}
		else
		{
			DestFeature2VO	feature = new DestFeature2VO();
			feature.setFeatureId(0);
			inv.addModel("feature",feature);
		}
		return "listFeatureItemText";
	}
	@JSON
	@Post("feature/item/text/list")
	public Object showFeatureItemText(@Param("featureItemId")int featureItemId) {
		return destService.findSubItemsForFeatureItem(featureItemId);
	}
	
	@Get("feature/item/text/vsave")
	public String toAddFeatureItemText() {
		return "addFeatureItemText";
	}
	@JSON
	@Post("feature/item/text/save")
	public Object saveFeatureItemText(BaseInfoVO infoVO) {
		destService.saveFeatureItemText(infoVO);
		return CommonResp.SUCCESS;
	}
	@Get("feature/item/text/vupdate")
	public String toUpdateFeatureItemText(Invocation inv,@Param("infoId")int infoId) {
		BaseInfoVO base = destService.findBaseInfoById(infoId);
		inv.addModel("base",base);
		return "updateFeatureItemText";
	}
	@JSON
	@Post("feature/item/text/update")
	public Object updateFeatureItemText(BaseInfoVO infoVO) {
		destService.updateFeatureItemText(infoVO);
		return CommonResp.SUCCESS;
	}
	@JSON
	@Post("feature/item/text/delete")
	public Object deleteFeatureItemText(BaseInfoVO infoVO) {
		destService.deleteFeatureItemText(infoVO);
		return CommonResp.SUCCESS;
	}
	/**************************目的地特色项的图文管理*end************************/
	/**************************目的地特色项图片管理**start*****************************/
	@Get("feature/item/image/vlist")
	public String toListFeatureItemImages(Invocation inv,@Param("infoId")int infoId,@Param("featureItemId")int featureItemId) {
		BaseInfoVO info = destService.findBaseInfoById(infoId);
		inv.addModel("info",info);
		DestFeatureItem2VO item = destService.findSimplestFeatureItemById(featureItemId);
		inv.addModel("item",item);
		if(item != null && item.getFeatureId() != 0) {
			//获取特色信息
			DestFeature2VO	feature = destService.findSimplestDestFeatureById(item.getFeatureId());
			inv.addModel("feature",feature);
			if(feature != null && feature.getDestId() != 0) {
				//获取目的地信息
				DestVO dest = destService.findSimplestDestById(feature.getDestId());
				inv.addModel("dest",dest);
			}
		}
		else
		{
			DestFeature2VO	feature = new DestFeature2VO();
			feature.setFeatureId(0);
			inv.addModel("feature",feature);
		}
		return "listFeatureItemImages";
	}
	@JSON
	@Post("feature/item/image/list")
	public Object showFeatureItemImages(@Param("infoId")int infoId) {
		return destService.findListFeatureItemImages(infoId);
	}
	@Get("feature/item/image/vsave")
	public String toAddFeatureItemImage() {
		return "addFeatureItemImage";
	}
	@JSON
	@Post("feature/item/image/save")
	public Object saveFeatureItemImage(BaseInfoVO infoVO) {
		destService.saveFeatureItemImage(infoVO);
		return CommonResp.SUCCESS;
	}
	@Get("feature/item/image/vupdate")
	public String toUpdateFeatureItemImage(Invocation inv,@Param("imageId")int imageId) {
		ImageVO images = infoService.findImageById(imageId);
		inv.addModel("images",images);
		return "updateFeatureItemImage";
	}
	@JSON
	@Post("feature/item/image/update")
	public Object updateFeatureItemImage(ImageVO image) {
		infoService.updateImage(image);
		return CommonResp.SUCCESS;
	}
	@JSON
	@Post("feature/item/image/delete")
	public Object deleteFeatureItemImage(ImageVO image) {
		infoService.deleteImage(image);
		return CommonResp.SUCCESS;
	}
	
	/**************************目的地特色项图片管理**end*****************************/
	/**************************独立发布特色项*start**************************/
	@Get("alone/feature/item/vlist")
	public String toListAloneFeatureItem() {
		return "listAloneFeatureItem";
	}
	@JSON
	@Post("alone/feature/item/list")
	public Object showAloneFeatureItem(PageVO page) {
		JSONPageData data = new JSONPageData();
		//按分页查询独立发布的特色项
		List<DestFeatureItem2VO> list = destService.findListAloneFeatureItem(page);
		//统计独立发布的特色项数目
		int total = destService.findAloneFeatureItemCount();
		data.setRows(list);
		data.setTotal(total);
		return data;
	}
	@Get("alone/feature/item/vsave")
	public String toAddAloneFeatureItem() {
		return "addAloneFeatureItem";
	}
	@JSON
	@Post("alone/feature/item/save")
	public Object saveAloneFeatureItem(DestFeatureItem2VO itemVO) {
		if(itemVO.getFeatureCategoryId() == SystemConfigHolder.getDestFeatureHotelCategoryId()){
			CommonResp comm = new CommonResp();
			comm.setResultCode(CommonResp.FAIL_CODE);
			comm.setResultMsg("住宿类型不支持独立发布!");
			return comm;
		}
		else
		{
			destService.saveDestFeatureItem(itemVO);
			return CommonResp.SUCCESS;
		}
	}
	@Get("alone/feature/item/vupdate")
	public String toUpdateAloneFeatureItem(Invocation inv,@Param("featureItemId")int featureItemId) {
		DestFeatureItem2VO item = destService.findFeatureItemById(featureItemId);
		inv.addModel("featureItem",item);
		return "updateAloneFeatureItem";
	}
	@JSON
	@Post("alone/feature/item/update")
	public Object updateAloneFeatureItem(DestFeatureItem2VO itemVO) {
		if(itemVO.getFeatureCategoryId() == SystemConfigHolder.getDestFeatureHotelCategoryId()){
			CommonResp comm = new CommonResp();
			comm.setResultCode(CommonResp.FAIL_CODE);
			comm.setResultMsg("住宿类型不支持独立发布!");
			return comm;
		}
		else
		{
			destService.updateDestFeatureItem(itemVO);
			return CommonResp.SUCCESS;
		}
	}
	@JSON
	@Post("alone/feature/item/delete")
	public Object deleteAloneFeatureItem(DestFeatureItem2VO item) {
		destService.deleteFeatureItem(item, item.getFeatureCategoryId());
		return CommonResp.SUCCESS;
	}
	@JSON
	@Post("feature/allcategory/list")
	public Object findListAllCategory() {
		return categoryService.findAllCategory();
	}
	/**************************独立发布特色项*end**************************/
	/**************************过期特色项*start**************************/
	@Get("expire/feature/item/vlist")
	public String toExpireFeatureItemVlist(){
		return "listExpireFeatureItem";
	}
	
	@JSON
	@Post("expire/feature/item/list")
	public Object listExpireFeatureItem(PageVO page){
		JSONPageData data = new JSONPageData();
		//按分页查询独立发布的特色项
		List<DestFeatureItem2VO> list = destService.findListExpireFeatureItem(page);
		//统计独立发布的特色项数目
		int total = destService.findExpireFeatureItemCount();
		data.setRows(list);
		data.setTotal(total);
		return data;
	}
	
	@Get("expire/feature/item/vupdate")
	public String toUpdateExpireFeatureItem(Invocation inv,@Param("featureItemId")int featureItemId){
		DestFeatureItem2VO item = destService.findFeatureItemById(featureItemId);
		inv.addModel("featureItem",item);
		return "updateExpireFeatureItem";
	}
	
	@JSON
	@Post("expire/feature/item/update")
	public Object updateExpireFeatureItem(DestFeatureItem2VO item){
		
		//判断修改后的失效时间是否大于原来的失效时间，并且大于当前时间，
		Timestamp oldExpireTime = item.getOldExpireTime();
		Timestamp expireTime = item.getExpireTime();
		if(expireTime.after(oldExpireTime))
		{
				//创建时间改为当前时间
				Date date = new Date();
				item.setCreateTime(date);
				//修改过期特色项
				destService.updateDestFeatureItem(item);
			
				return CommonResp.SUCCESS;
		}
		else{
			CommonResp res = CommonResp.FAIL;
			res.setResultMsg("实效时间未填写或者新的失效时间小于等于原有失效的时间!");
			return res;
		}
	}
	@JSON
	@Post("expire/feature/item/delete")
	public Object deleteExpireFeatureItem(DestFeatureItem2VO item){
		destService.deleteExpireFeatureItem(item);
		return CommonResp.SUCCESS;
	}
	/**************************过期特色项*end**************************/
	
	/******************目的地交通信息升级**start***********************/
	@Get("traffic/level1/vlist")
	public String toListDestTrafficLevel1(Invocation inv,@Param("destId")int destId){
		DestVO dest = destService.findDestById(destId);
		inv.addModel("dest",dest);
		return "listDestTrafficLevel1";
	}
	@JSON
	@Post("traffic/level1/list")
	public Object listDestTrafficLevel1(@Param("destId")int destId){
		List<DestTraffic2VO> list = destTrafficService.findDestTrafficLevel1ByDestId(destId);
		return list;
	}
	@Get("traffic/level1/vsave")
	public String toAddDestTrafficLevel1(){
		return "addDestTrafficLevel1"; 
	}
	@JSON
	@Post("traffic/level1/save")
	public Object saveDestTraffic2(DestTraffic2VO traffic){
		destTrafficService.saveDestTrafficLevel1(traffic);
		return CommonResp.SUCCESS;
	}
	@Get("traffic/level1/vupdate")
	public String toUpdateDestTraffic2(Invocation inv,@Param("trafficId")int trafficId){
		DestTraffic2VO traffic = destTrafficService.findDestTraffic2ById(trafficId);
		inv.addModel("destTraffic",traffic);
		return "updateDestTrafficLevel1";
	}
	@JSON
	@Post("traffic/level1/update")
	public Object updateDestTraffic2(DestTraffic2VO traffic){
		destTrafficService.updateDestTraffic2(traffic);
		return CommonResp.SUCCESS;
	}
	@JSON
	@Post("traffic/level1/delete")
	public Object deleteDestTraffic(DestTraffic2VO traffic){
		destTrafficService.deleteDestTraffic(traffic.getDestId(),traffic.getTrafficType());
		return CommonResp.SUCCESS;
	}
	/*****************目的地交通的第二层级管理**********************************/
	@Get("traffic/level2/vlist")
	public String toListDestTrafficLevel2(Invocation inv,@Param("destId")int destId,@Param("parentId")int trafficId){
		DestVO dest = destService.findDestById(destId);
		inv.addModel("dest",dest);
		DestTraffic2VO traffic = destTrafficService.findDestTraffic2ById(trafficId);
		inv.addModel("traffic",traffic);
		
		return "listDestTrafficLevel2";
	}
	@JSON
	@Post("traffic/level2/list")
	public Object listDestTrafficLevel2(@Param("parentId")int parentId){
		return destTrafficService.findListDestTrafficLevel(parentId);
	}
	@Get("traffic/level2/vsave")
	public String toAddDestTrafficLevel2(){
		return "addDestTrafficLevel2";
	}
	@JSON
	@Post("traffic/level2/save")
	public Object saveDestTrafficLevel2(DestTraffic2VO traffic){
		destTrafficService.saveDestTrafficLevel2(traffic);
		return CommonResp.SUCCESS;
	}
	@Get("traffic/level2/vupdate")
	public String toUpdateDestTrafficLevel2(Invocation inv,@Param("trafficId")int trafficId){
		DestTraffic2VO traffic = destTrafficService.findDestTraffic2ById(trafficId);
		inv.addModel("destTraffic",traffic);
		return "updateDestTrafficLevel2";
	}
	@JSON
	@Post("traffic/level2/update")
	public Object updateDestTrafficLevel2(DestTraffic2VO traffic){
		destTrafficService.updateDestTrafficLevel(traffic);
		return CommonResp.SUCCESS;
	}
	@JSON
	@Post("traffic/level2/delete")
	public Object deleteDestTrafficLevel2(DestTraffic2VO traffic){
		destTrafficService.deleteDestTrafficLevel2(traffic.getTrafficId());
		return CommonResp.SUCCESS;
	}
	
	/*****************目的地交通的第三层级管理**********************************/
	@Get("traffic/level3/vlist")
	public String toListDestTrafficLevel3(Invocation inv,@Param("destId")int destId,@Param("trafficL1Id")int trafficL1Id,@Param("trafficL2Id")int trafficL2Id){
		//查询目的地信息
		DestVO dest = destService.findDestById(destId);
		inv.addModel("dest",dest);
		//查询一级交通类别信息
		DestTraffic2VO trafficL1 = destTrafficService.findDestTraffic2ById(trafficL1Id);
		inv.addModel("trafficL1",trafficL1);
		//查询二级交通类别项信息
		DestTraffic2VO trafficL2 = destTrafficService.findDestTraffic2ById(trafficL2Id);
		inv.addModel("trafficL2",trafficL2);
		return "listDestTrafficLevel3";
	}
	@JSON
	@Post("traffic/level3/list")
	public Object listDestTrafficLevel3(@Param("parentId")int trafficId){
		
		return destTrafficService.findListDestTrafficLevel(trafficId);
	}
	@Get("traffic/level3/vsave")
	public String toAddDestTrafficLevel3(){
		
		return "addDestTrafficLevel3";
	}
	@JSON
	@Post("traffic/level3/save")
	public Object saveDestTrafficLevel3(DestTraffic2VO traffic){
		destTrafficService.saveDestTrafficLevel3(traffic);
		return CommonResp.SUCCESS;
	}
	@Get("traffic/level3/vupdate")
	public String toUpdateDestTrafficLevel3(Invocation inv,@Param("trafficId")int trafficId){
		DestTraffic2VO traffic = destTrafficService.findDestTraffic2ById(trafficId);
		inv.addModel("destTraffic",traffic);
		return "updateDestTrafficLevel3";
	}
	@JSON
	@Post("traffic/level3/update")
	public Object updateDestTrafficLevel3(DestTraffic2VO traffic){
		destTrafficService.updateDestTrafficLevel(traffic);
		return CommonResp.SUCCESS;
	}
	@JSON
	@Post()
	public Object deleteDestTrafficLevel3(DestTraffic2VO traffic){
		destTrafficService.deleteDestTrafficLevel3(traffic.getTrafficId());
		return CommonResp.SUCCESS;
	}
	/******************目的地交通信息升级**end***********************/
}
